function addTwoNumbers(s1, s2) {
  let i = s1.length-1
  let j = s2.length-1
  let add = 0
  const res = []
  while(i>=0 || j>=0 || add!==0) {
    const x = i>=0 ? Number(s1[i--]) : 0
    const y = j>=0 ? Number(s2[j--]) : 0
    const sum = x + y + add
    res.push(sum%10)
    add = Math.floor(sum/10)
  }
  return res.reverse().join('')
}
const s1 = "125"
const s2 = "456"
console.log(addTwoNumbers(s1, s2)) //581